package com.service.device;

import com.dao.secondary.device.DeviceObdVersionInfoMapper;
import com.dao.secondary.device.DevicePcbVersionInfoMapper;
import com.github.pagehelper.PageHelper;
import com.model.domain.device.GetDeviceObdVersionInfoDO;
import com.model.domain.device.GetDevicePcbVersionInfoDO;
import com.model.pojo.device.Device25ObdVersionInfo;
import com.model.pojo.device.DevicePcbVersionInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * @Author: zql
 * @Description: PMD播种机版本号信息管理服务
 * @Data: 2023-07-16
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DeviceObdVersionInfoService {
    private final DeviceObdVersionInfoMapper deviceObdVersionInfoMapper;

    public List<Device25ObdVersionInfo> getPageList(GetDeviceObdVersionInfoDO getDeviceObdVersionInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getDeviceObdVersionInfoDO.getPage(),getDeviceObdVersionInfoDO.getPageSize(),getDeviceObdVersionInfoDO.getSortRow()+getDeviceObdVersionInfoDO.getSortOrder());
        return deviceObdVersionInfoMapper.selectList(getDeviceObdVersionInfoDO);
    }
    public List<Device25ObdVersionInfo> getAllList(GetDeviceObdVersionInfoDO getDeviceObdVersionInfoDO){
        PageHelper.clearPage();
        PageHelper.orderBy(getDeviceObdVersionInfoDO.getSortRow()+getDeviceObdVersionInfoDO.getSortOrder());
        return deviceObdVersionInfoMapper.selectList(getDeviceObdVersionInfoDO);
    }

    public int save(Device25ObdVersionInfo info){
        info.setCreateTime(new Date());
        return deviceObdVersionInfoMapper.insertSelective(info);
    }
    public int update(Device25ObdVersionInfo info){
        return deviceObdVersionInfoMapper.updateByPrimaryKeySelective(info);
    }

    public void delete(Long id){
        deviceObdVersionInfoMapper.deleteByPrimaryKey(id);
    }
    public Device25ObdVersionInfo getById(Long id){
        return deviceObdVersionInfoMapper.selectByPrimaryKey(id);
    }

    public List<Device25ObdVersionInfo> getByNewVersion(String newVersion){
        return deviceObdVersionInfoMapper.selectByNewVersion(newVersion);
    }
}
